package com.chen.demo.javase.annotaion.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @author chenhongwei
 * @date 2019/12/15 14:03
 **/
public class JDKProxy {

    public static void main(String[] args) {

        InvocationHandler invocationHandler = new InVocationTest(new RealSubject());

         Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[]{Subject.class},invocationHandler);
    }


    public  interface   Subject{
        void  operation();
    }


    public static class RealSubject implements  Subject {

        @Override
        public void operation() {

        }
    }


    public static class InVocationTest implements InvocationHandler{
        private Subject target;

        @Override
        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
            return null;
        }

        public InVocationTest(Subject target) {
            this.target = target;
        }
    }
}
